package com.mentaleye.dal.dao.mybatis;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.mentaleye.dal.dao.OaClassDao;
import com.mentaleye.dal.model.OaClass;
import com.mentaleye.dal.model.OaClassExample;
import com.mentaleye.dal.service.OaClassMapper;

@Repository
public class OaClassDaoImpl extends BaseDao implements OaClassDao{

	@Autowired private OaClassMapper oaclassMapper;
	
	@Override
	public boolean addOaClass(OaClass oaclass) {
		return getResultByInt(oaclassMapper.insert(oaclass));
	}

	@Override
	public boolean updateOaClass(OaClass oaclass) {
		return getResultByInt(oaclassMapper.updateByPrimaryKeySelective(oaclass));
	}
	
	@Override
	public boolean updateOaClassByList(List<Integer> ids,OaClass oaClass){
		OaClassExample example = new OaClassExample();
		example.createCriteria().andOaclassIdIn(ids);
		return getResultByInt(oaclassMapper.updateByExampleSelective(oaClass, example));
	}

	@Override
	public boolean deleteOaClass(List<Integer> ids) {
		OaClassExample example = new OaClassExample();
		example.createCriteria().andOaclassIdIn(ids);
		return getResultByInt(oaclassMapper.deleteByExample(example));
	}
	
	@Override
	public boolean deleteOaClassNotIn(List<Integer> ids){
		OaClassExample example = new OaClassExample();
		example.createCriteria().andOaclassIdNotIn(ids);
		return getResultByInt(oaclassMapper.deleteByExample(example));
	}

	@Override
	public List<OaClass> selectOaclassList(Map<String, Object> map) {
		return oaclassMapper.selectByMap(map);
	}

	@Override
	public OaClass selectOaclassData(OaClass oaclass) {
		return oaclassMapper.selectByNameOrId(oaclass);
	}
	
	public OaClass selectOaclassById(Integer oaclassId){
		return oaclassMapper.selectByPrimaryKey(oaclassId);
	}
	@Override
	public List<OaClass> select(OaClassExample example){
		return oaclassMapper.selectByExample(example);
	}

	@Override
	public List<OaClass> selectAllOaClass() {
		return oaclassMapper.selectAllOaClass();
	}

	@Override
	public List<Map<String, Object>> getListByMap(Map<String, Object> map) {
		return this.oaclassMapper.getListByMap(map);
	}

	@Override
	public int getCountByExample(OaClassExample example) {
		return this.oaclassMapper.countByExample(example);
	}

}
